package cn.stazxr.component;

import javax.swing.*;

/**
 * Package: cn.stazxr.component
 *
 * @Author: stazxr
 * @Create: 2023/12/11
 * @Version: v1.0
 **/
public class ProgressBarTest {
    public static void main(String[] args) {
        JFrame frame = new JFrame("我是标题");
        frame.setBounds(500, 300, 500, 300);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLayout(null);

        JProgressBar bar = new JProgressBar();
        bar.setMaximum(100);
        bar.setValue(10);
        bar.setBounds(20, 20, 450, 15);
        frame.add(bar);

        frame.setVisible(true);

        while (bar.getValue() < 100) {
            bar.setValue(bar.getValue() + 1);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("加载完成");
    }
}
